package com.kxf.androidtestdemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

import com.kxf.androidtestdemo.R;
import com.kxf.utils.Util;

public class SystemSettingActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_system_setting);
    }

    public void onClickGoGpsSetting(View view) {
        gotoSetGPS();
    }
    /**
     * 转到设置GPS界面
     */
    public void gotoSetGPS() {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try{
            startActivityForResult(intent, 100);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Log.i("MainActivity", "onActivityResult requestCode=" + requestCode);
        Log.i("MainActivity", "onActivityResult resultCode=" + resultCode);
        Log.i("MainActivity", "onActivityResult data=" + Util.getIntentExtrasToString(data));
    }
}